import Vue from 'vue'

// 腾讯二维码验证
const appid = '2094307004'

export default () => {
  Vue.prototype.$captcha = () => {
    return new Promise((resolve, reject) => {
      const captcha = new TencentCaptcha(appid, ({ ret, ticket, randstr }) => {
        if (!ret) {
          resolve({ ticket, rand_str: randstr })
        } else {
          reject()
        }
      })
      captcha.show() // 显示验证码
    })
  }
}
